package com.wdc.n1;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic = "c.Test8Locks")
public class Test8Locks {


    public static void main(String[] args) {
        //有可能出现 2，1 也有可能出现 1，2
        Number n1 = new Number();
        new Thread(() -> {
            log.debug("begin");
            n1.a();
        }).start();

        new Thread(() -> {
            log.debug("begin");
            n1.b();
        }).start();


    }




}


@Slf4j(topic = "c.Number")
class Number {

    public synchronized void a() {
        log.debug("1");

    }

    public synchronized void b() {
        log.debug("2");

    }

}
